package com.ybc;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CController {

    //无参构造器
    public CController() {
        System.out.println("CController 无参构造器");
    }

    @Lazy
    @Autowired
    private ServiceA serviceA;

    @Lazy
    @Autowired
    private ServiceB serviceB;


    @GetMapping("/ahello")
    public String aHello(){

        String aHello =  serviceA.hello();

        return "c调用： "+aHello;
    }

    @GetMapping("/aname")
    public String aName(){

        String aName =  serviceA.name();
        return "c调用： "+aName;
    }

    @GetMapping("/arepeat")
    public String aRepeat(String name){
        System.out.println(name);
        String aRepeat =  serviceA.repeat(name);
        return "c调用： "+aRepeat;
    }

    @GetMapping("/bhello")
    public String bHello(){
        String bHello =  serviceB.hello();
        return "c调用： "+bHello;
    }
}
